home *** CD-ROM | disk | FTP | other *** search
/ MacHome 2001 May / MacHome CD (May 2001).iso / mac / Stuff / Software / Tools / The Fragmalyzer 1.5.1 / Extras / Headers & Libraries / FrazBinaries.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-03  |  7.2 KB  |  239 lines  |  [TEXT/CWIE]

  1. /*     
  2.     File:      FrazBinaries.h
  3.     
  4.     Version:    1.5
  5.     Date:    August 2000
  6.     
  7.     Copyright © 1999-2000 Dan Wright, All rights reserved.
  8.     
  9.     Bugs?:     Please include the name of this file, the version, and the date (above). 
  10.             Send bug reports to danwr@kagi.com. 
  11.     
  12.     Updates:     http://www.halcyon.com/danwr/smoothie.html
  13. */
  14.  
  15. #ifndef __FRAZBINARIES__
  16. #define __FRAZBINARIES__
  17.  
  18.  
  19. #if PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22.  
  23. #include "FrazAPI.h"
  24. #include "FrazRegistry.h"
  25.  
  26. #ifdef __cplusplus
  27. extern "C"    {
  28. #endif
  29.  
  30. #if PRAGMA_IMPORT
  31. #pragma import on
  32. #endif
  33.  
  34. #if PRAGMA_STRUCT_ALIGN
  35.     #pragma options align=mac68k
  36. #elif PRAGMA_STRUCT_PACKPUSH
  37.     #pragma pack(push, 2)
  38. #elif PRAGMA_STRUCT_PACK
  39.     #pragma pack(2)
  40. #endif
  41.  
  42.  
  43. enum    {
  44.     /* binary formats */
  45.     kBinFormatPEF         = FOUR_CHAR_CODE('peff'),    /* standard CFM format. Defined in PEFBinaryFormat.h. */
  46.                                                 
  47.     kBinFormatXCOFF    = FOUR_CHAR_CODE('xcof'),    /* Defined in XCOFF.h. Reserved for future use. */
  48.     
  49.     kBinFormatMachO    = FOUR_CHAR_CODE('Mach'),    /* NeXT/OpenStep/Mach/Rhapsody/OS X. Reserved for future use. */
  50.     
  51.     kBinFormatCOFF    = FOUR_CHAR_CODE('coff'),    /* Reserved for the heck of it. */
  52.     
  53.     kBinFormatVectorLib = FOUR_CHAR_CODE('VLib'),    /* OS X. Reserved for future use. */
  54.     kBinFormatBridgeLib = FOUR_CHAR_CODE('BLib'),    /* OS X. Reserved for future use. */
  55.     
  56.     kBinFormatPEF2    = FOUR_CHAR_CODE('PEF '),    /* Reserved for future use. */
  57.     kBinFormatRanLib    = FOUR_CHAR_CODE('ranl')    /* OS X. Reserved for future use. */
  58.     };
  59.     
  60. enum {     /* error codes */
  61.     errUnsupportedBinFormat    = 9000,        /* no plug-in for format */
  62.     errIncompatibleBFX         = 9001,        /* binary format plug-in exists but is incompatible w/us or OS version */
  63.     errNotFragment         = 9002,        /* not a fragment (or incorrect BinFormat specified) */
  64.     errCorruptFragment         = 9003,
  65.     errBadReference        = 9004,        /* bad BrowserRef, FragmentRef, LibraryRef, WindowRef... */
  66.     errEndOfList            = 9005,        /* index beyond end of list */
  67.     errUnsupportedOp        = 9006,        /* operation not supported for this format */
  68.     errDuplicateLocator        = 9007,        /* locator already registered */
  69.     errNoFragmentsFound    = 9008        /* BFXScan found no fragments */
  70.     };
  71.         
  72. typedef struct FrazDiskFlatLocator
  73.     {
  74.     ConstFSSpecPtr fileSpec;
  75.     UInt32        offset;
  76.     UInt32        length;
  77.     } FrazDiskFlatLocator;
  78.  
  79. typedef struct FrazMemoryLocator
  80.     {
  81.     LogicalAddress    address;
  82.     UInt32        length;
  83.     Boolean        inPlace;
  84.     UInt8        reservedA;
  85.     UInt16        reservedB;
  86.     } FrazMemoryLocator;
  87.  
  88. typedef struct FrazResourceLocator
  89.     {
  90.     ConstFSSpecPtr fileSpec;
  91.     OSType        rsrcType;
  92.     SInt16        rsrcID;
  93.     UInt16        offset;        /* note: this differs from CFragSystem7SegmentedLocator, where this is a reserved field */
  94.     } FrazResourceLocator;
  95.  
  96. typedef struct FrazGenericLocator
  97.     {
  98.     UInt32        field1;
  99.     UInt32        field2;
  100.     UInt32        field3;
  101.     } FrazGenericLocator;
  102.         
  103. typedef struct FrazLocator
  104.     {
  105.     SInt32        where;
  106.     union {
  107.         FrazDiskFlatLocator     onDisk;
  108.         FrazMemoryLocator    inMem;
  109.         FrazResourceLocator inSegs;
  110.         FrazGenericLocator    generic;
  111.         } u;
  112.     } FrazLocator;
  113.  
  114. typedef const FrazLocator *ConstFrazLocatorPtr;
  115.  
  116. #define FrazLocatorIsFileLocator(where) \
  117.         (CFragHasFileLocation(where)     ||  (where < 0))
  118.  
  119.  
  120. typedef FourCharCode        BinFormat;    
  121.  
  122.  
  123. typedef struct OpaqueBinFragmentAccess *FrazAccessRef;
  124. typedef FrazAccessRef            FrazLocatorRef;        /* old name */
  125.  
  126. typedef void*                    GenericReference;
  127.         
  128. enum {
  129.     // fragment properties
  130.     kFrazPropLibraryCount     = FOUR_CHAR_CODE('lcnt'),     /* UInt32 */
  131.     kFrazPropSectionCount     = FOUR_CHAR_CODE('xcnt'),    /* UInt16 */
  132.     
  133.     kFrazPropLibMapPrivately = FOUR_CHAR_CODE('priv'),    /* Boolean */
  134.     kFrazPropAppSubdirID     = FOUR_CHAR_CODE('dird'),    /* SInt32 (directory ID) */
  135.     kFrazPropAppLibDirID    = FOUR_CHAR_CODE('dird'),    /* directory ID */
  136.     kFrazPropAppStackSize    = pAppStackSize,            /* UInt32 */
  137.     
  138.     // section properties
  139.     kFrazPropSharing         = pSharingKind,    
  140.     kFrazPropOffset         = FOUR_CHAR_CODE('offs'),        /* UInt32 */
  141.     kFrazPropAlignment         = FOUR_CHAR_CODE('alig'),    /* UInt8 (power of 2) */
  142.     kFrazPropDefaultAddress     = FOUR_CHAR_CODE('defa'),    /* UInt32 */
  143.     kFrazPropSizeOnDisk     = FOUR_CHAR_CODE('cbod'),
  144.     kFrazPropSizeLoaded     = FOUR_CHAR_CODE('cbim'),
  145.     kFrazPropSectionKind     = FOUR_CHAR_CODE('kind'),
  146.     
  147.     kFrazPropSectionSegment    = FOUR_CHAR_CODE('zSeg'),    /* typeChar (name) */
  148.     
  149.     kFrazPropContainsCode    = FOUR_CHAR_CODE('$cod'),    /* Boolean */
  150.     
  151.     // main/init/term: properties of section
  152.     kFrazPropMain            = FOUR_CHAR_CODE('main'),    /* UInt32 (offset) */
  153.     kFrazPropInitialization    = FOUR_CHAR_CODE('init'),
  154.     kFrazPropTermination    = FOUR_CHAR_CODE('term'),
  155.     
  156.     // library properties
  157.     kFrazPropWeakLink        = pWeakLink,    /* boolean */
  158.     kFrazPropInitBefore        = FOUR_CHAR_CODE('ipre'),    /* boolean */
  159.     kFrazPropSymbolCount     = FOUR_CHAR_CODE('scnt'),    /* UInt32 (can be derived) */
  160.     kFrazPropCurrentVersion = FOUR_CHAR_CODE('vers'),    /* UInt32 */
  161.     kFrazPropOldestCompatible = FOUR_CHAR_CODE('verz'),    /* UInt32 */
  162.     
  163.     // symbol properties
  164.     kFrazPropSymbolClass     = FOUR_CHAR_CODE('csym'),    /* CFragSymbolClass */
  165.     kFrazPropSection         = FOUR_CHAR_CODE('sect')    /* SInt16 */
  166.     // also kFrazPropOffset, kFrazPropWeakLink
  167.     
  168.     };
  169.     
  170. enum {
  171.     /* values for kFrazPropSectionKind */
  172.     kFrazCodeSection            = 0,            /* Code, presumed pure & position independent.*/
  173.     kFrazUnpackedDataSection        = 1,            /* Unpacked writeable data.*/
  174.     kFrazPackedDataSection        = 2,            /* Packed writeable data.*/
  175.     kFrazDataSection            = kFrazUnpackedDataSection,    
  176.     kFrazConstantSection        = 3,            /* Read-only data.*/
  177.     kFrazLoaderSection            = 4,            /* Loader tables.*/
  178.     kFrazDebugSection            = 5,            /* Reserved for future use.*/
  179.     kFrazExecDataSection        = 6,            /* Intermixed code and writeable data.*/
  180.     kFrazExceptionSection        = 7,            /* Reserved for future use.*/
  181.     kFrazTracebackSection        = 8            /* Reserved for future use.*/
  182.     };
  183.     
  184. enum {
  185.     /* values for kFrazPropSharing */
  186.     kFrazPrivateShare            = 0,            /* Shared only within a "private" closure. */
  187.     kFrazProcessShare            = 1,            /* Shared within a single process.*/
  188.     kFrazGlobalShare            = 4,            /* Shared across the entire system.*/
  189.     kFrazProtectedShare            = 5            /* Readable across the entire system, writeable only to privileged code.*/    
  190.     };
  191.  
  192. // --------------------------------------------------------------------------------------
  193.  
  194. pascal OSErr FrazOpen(ConstFrazLocatorPtr, SInt16 fsPerm, FrazLocatorRef *pRef);
  195. pascal void    FrazClose(FrazLocatorRef);
  196. pascal OSErr FrazRead(FrazLocatorRef, UInt32 offset, Size *pcb, void *buf);
  197. pascal OSErr FrazWrite(FrazLocatorRef, UInt32 offset, Size cb, void *buf);
  198. pascal OSErr FrazGetFragmentSize(BinFormat, FrazLocatorRef, Size *pcb);
  199.  
  200. pascal Boolean FrazReferenceIsValid(OSType theClass, GenericReference);
  201.  
  202. enum {
  203.     kFrazScanExports = 1,
  204.     kFrazScanImportSymbols = 2,
  205.     kFrazScanLibraries = 6,
  206.     kFrazScanFragmentInfo = 8,
  207.     kFrazScanAll = kFrazScanFragmentInfo | kFrazScanLibraries | kFrazScanExports,
  208.     
  209.     kFrazScanRelocate = 16    // Locator has become invalid
  210.     };
  211.     
  212. pascal OSErr FrazRescanFragment(FragmentRef fragment, long scanFlags);
  213.  
  214. pascal ConstFrazLocatorPtr FrazGetFragmentLocator(FragmentRef);
  215.  
  216. pascal FragmentRef FrazFindFragmentByLocator(BrowserRef *inoutBrowser, ConstFrazLocatorPtr);
  217. pascal FragmentRef FrazFindFragmentByLocatorAndName(BrowserRef *inoutBrowser, ConstFrazLocatorPtr, ConstStringPtr);
  218.  
  219.  
  220.  
  221. #if PRAGMA_STRUCT_ALIGN
  222.     #pragma options align=reset
  223. #elif PRAGMA_STRUCT_PACKPUSH
  224.     #pragma pack(pop)
  225. #elif PRAGMA_STRUCT_PACK
  226.     #pragma pack()
  227. #endif
  228.  
  229. #ifdef PRAGMA_IMPORT_OFF
  230. #pragma import off
  231. #elif PRAGMA_IMPORT
  232. #pragma import reset
  233. #endif
  234.  
  235. #ifdef __cplusplus
  236.         }
  237. #endif
  238.  
  239. #endif /* __FRAZBINARIES__ */